<?php
require_once $GLOBALS['ROO'] . 'Modules/Geo/class.geo.php';
require_once $GLOBALS['ROO'] . 'Modules/Financeiro/class.agency.php';
$MDAC = 'ED';

if ($_POST['AID'] != '') {
    $OBJCTAC = $_POST['AID'];
    $GET = $GLOBALS['MYT']->db_array("SELECT *
			from beneficiarioscuentas
			WHERE cb_ID = {$OBJCTAC}");
    # Modo Read das propriedades da conta com erros
    #if ($GET[1]['cb_Status'] > 2) {
    #$MDAC = 'RD';
    #}
} else {
    $MDAC = 'ED';
    $VWACDT = 1;
    $GET[0] = 1;
    $OBJCTAC = 0;
    $ACVARS = $GLOBALS['MYT']->db_array("DESCRIBE beneficiarioscuentas");
    for ($v = 1; $v <= $ACVARS[0]; $v++) {
        $ACVAR = $ACVARS[$v]['Field'];
        $GET[1][$ACVAR] = '';
    }
}
if (!isset($GET[1])) {
    die("Error:00031");
}
$ReceiverAccountGeo = New Geo();
$ReceiverAgency = New Agency();
$GetAccountProperties = $GLOBALS['MYT']->db_array("SELECT BnfPais FROM beneficiarios WHERE BnfNumero = {$_POST['RID']}");
?>
<div id="Line">
    <DIV id="ACMSG"></DIV>
    <table width="100%" border="0" cellpadding="1" cellspacing="3"
           bgcolor="#E5E5E5">
        <tr>
            <td colspan="10">
                <div style="background-color: '#F4F4F4'"><b>Dados da Conta</b>
		Situação: <?php
mn_field('hselect', 'ED', 'cb_Status', $GET[1]['cb_Status'], "Eliminada;Regular;Bloqueada#1;2;4", '', '', '');
/*
  if ($MDAC == 'RD') {
  mn_field('button','ED','MDACED','Modificar','12','12','False','SUBMIT" onClick="subform(\'ReceiverProperties\',\'NWAC\');');
  } */
?></div>
            </td>
        </tr>
        <tr>
            <td>Banco:</td>
            <td colspan="5"><?php echo $ReceiverAgency->ListBanks($GET[1]['cb_Banco'], 'cb_Banco', $GetAccountProperties[1]['BnfPais']); ?></td>
            <td colspan="4"><div id="georf"><?php echo $ReceiverAccountGeo->GetRegion($GET[1]['cb_AgRegion'], 'cb_AgRegion', 'cb_CiudadSucursal', $GetAccountProperties[1]['BnfPais'], 0, 'geocf', 'ED'); ?></div></td>
        </tr>
        <tr>
            <td>Tipo:</td>
            <td><?php
if ($MDAC == 'ED') {
    $ACTypes = "SELECT REF AS ID, TYPE_NAME AS NAME FROM hf_actypes WHERE TYPE_COUNTRY = 76";
    $Label = '';
} elseif ($MDAC == 'RD') {
    $ACTypes = '';
    $Label = "SELECT TYPE_NAME AS NAME FROM hf_actypes WHERE REF = " . $GET[1]['cb_Cuenta'];
}
mn_field('select', $MDAC, 'cb_TipoCuenta', $GET[1]['cb_TipoCuenta'], $ACTypes, $Label, 'False', '');
?></td>
            <td><?php
if ($GetAccountProperties[1]['BnfPais'] == 826) {
    $GET[1]['cb_CountryAgencyDesignation'] = 2;
} else {
    $GET[1]['cb_CountryAgencyDesignation'] = 1;
}
mn_field('hselect', $MDAC, 'cb_CountryAgencyDesignation', $GET[1]['cb_CountryAgencyDesignation'], "Agencia;Sort Code#1;2", $Label, '', '" disabled readonly="');
?></td>
            <td>
                <div id="fina"><?php echo $ReceiverAgency->ReceiverAgency($GET[1]['cb_Sucursal'], 'cb_Sucursal'); ?></div>
            </td>
            <td NOWRAP><script>

                if(document.ReceiverProperties.cb_AccountNumberType.value==1) {
                    AcNumberProp1.style.display='inline';
                    AcNumberProp2.style.display='inline';
                    AcNumberProp3.style.display='inline';
                    document.ReceiverProperties.cb_Cuenta_prx.style.display='inline';
                    document.ReceiverProperties.cb_Cuenta.length=10;
                    document.ReceiverProperties.cb_Cuenta.size=10;
                    document.ReceiverProperties.cb_Cuenta_sux.style.display='inline';
                    document.ReceiverProperties.cb_Cuenta_mod.style.display='inline';

                }
                if (document.ReceiverProperties.cb_AccountNumberType.value>1) {
                    AcNumberProp1.style.display='none';
                    AcNumberProp2.style.display='none';
                    AcNumberProp3.style.display='none';
                    document.ReceiverProperties.cb_Cuenta_prx.style.display='none';
                    document.ReceiverProperties.cb_Cuenta.length=34;
                    document.ReceiverProperties.cb_Cuenta.size=34;
                    document.ReceiverProperties.cb_Cuenta_sux.style.display='none';
                    document.ReceiverProperties.cb_Cuenta_mod.style.display='none';
                    document.ReceiverProperties.cb_TipoCuenta.disabled=true;
                    document.ReceiverProperties.cb_AgRegion.disabled=true;
                }

                </script> <?php
$qr_AccountNumberType = "SELECT ant_ID AS ID, ant_Name AS NAME FROM hf_acnumbertypes";
mn_field('select', $MDAC, 'cb_AccountNumberType', $GET[1]['cb_TipoNr'], $qr_AccountNumberType, '', '', '" onChange="
			if(document.ReceiverProperties.cb_AccountNumberType.value==1) {
				AcNumberProp1.style.display=\'inline\';
				AcNumberProp2.style.display=\'inline\';
				AcNumberProp3.style.display=\'inline\';
				document.ReceiverProperties.cb_Cuenta_prx.style.display=\'inline\';
				document.ReceiverProperties.cb_Cuenta.length=10;
				document.ReceiverProperties.cb_Cuenta.size=10;
				document.ReceiverProperties.cb_Cuenta_sux.style.display=\'inline\';
				document.ReceiverProperties.cb_Cuenta_mod.style.display=\'inline\';
				document.ReceiverProperties.cb_TipoCuenta.disabled=false;
				document.ReceiverProperties.cb_AgRegion.disabled=false;

			}
			if (document.ReceiverProperties.cb_AccountNumberType.value>1) {
				AcNumberProp1.style.display=\'none\';
				AcNumberProp2.style.display=\'none\';
				AcNumberProp3.style.display=\'none\';
				document.ReceiverProperties.cb_Cuenta_prx.style.display=\'none\';
				document.ReceiverProperties.cb_Cuenta.length=34;
				document.ReceiverProperties.cb_Cuenta.size=34;
				document.ReceiverProperties.cb_Cuenta_sux.style.display=\'none\';
				document.ReceiverProperties.cb_Cuenta_mod.style.display=\'none\';
				document.ReceiverProperties.cb_TipoCuenta.disabled=true;
				document.ReceiverProperties.cb_AgRegion.disabled=true;
			}');
?></td>
            <td NOWRAP><?php
                mn_field('text', $MDAC, 'cb_Cuenta_prx', $GET[1]['cb_Cuenta_prx'], '4', '4', 'False', '');
                echo '<span id="AcNumberProp1"> / </span>';
                mn_field('text', $MDAC, 'cb_Cuenta', $GET[1]['cb_Cuenta'], '34', '10', '', '');
                echo '<span id="AcNumberProp2"> - </span>';
                mn_field('text', $MDAC, 'cb_Cuenta_sux', $GET[1]['cb_Cuenta_sux'], '2', '2', 'False', '');
                echo '<span id="AcNumberProp3"> md.</span>';
                mn_field('text', $MDAC, 'cb_Cuenta_mod', $GET[1]['cb_Cuenta_mod'], '1', '1', 'False', '" style="font-size:10px; border:\'1px solid #006633\'');

                // Criação de Agencias no Caso de restrição de colocacao manual de agencia. // Outra:
                //mn_field('text','ED','NewFinA','','10','5','','');
                //mn_field('button','ED','SubFinA','+','','','','');
?></td>
            <td width="50%">
                <div id="geocf"><?php echo $ReceiverAccountGeo->GetCity($GET[1]['cb_CiudadSucursal'], 'cb_CiudadSucursal', $GET[1]['cb_AgRegion'], $GetAccountProperties[1]['BnfPais'], 'ED'); ?></div>
            </td>
        </tr>
        <tr>
            <td colspan="10">
                <div style="text-align: 'center'; background-color: '#F4F4F4'"><?php
                if ($MDAC == 'ED') {
                    mn_field('button', 'ED', 'PRSVAC', 'Guardar', '12', '12', 'False', 'SUBMIT" onClick="
	document.ReceiverProperties.action=\'_response/call.php?get=Operative/opv_receiveraccount\';
	subform(\'ReceiverProperties\',\'ACMSG\');');
                    mn_field('button', 'ED', 'PRACAB', 'Anular', '12', '12', 'False', 'SUBMIT" onClick="
                        document.getElementById(\'NWAC\').innerHTML=\'\';');
                } ?></div>
            </td>
        </tr>
    </table>
</div>